package com.douyin.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("parse_record")
public class ParseRecord {
    @TableId(type = IdType.AUTO)
    private Long id;
    
    // 用户和视频基本信息
    private Long userId;
    private String originalUrl;
    private String videoId;
    private String videoTitle;
    private String videoDescription;
    private String videoCover;
    private String authorName;
    private String authorId;
    
    // 解析结果相关
    private String parseResult;
    private String downloadUrls;  // JSON格式存储多种清晰度链接
    private String parseMethod;   // 解析方法: browser/third-party-api
    
    // 文件信息
    private String fileType;
    private Long fileSize;
    private Integer duration;
    private String videoQuality;
    private String videoResolution;
    private Integer bitrate;
    private Integer fps;
    
    // 状态和错误信息
    private Integer status;
    private String errorMessage;
    private String errorCode;
    private Integer retryCount;
    private Integer parseTime;
    
    // 下载统计
    private Integer downloadCount;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastDownloadAt;
    
    // 来源信息
    private String sourcePlatform;  // douyin/tiktok/kuaishou
    private String parseSource;     // miniprogram/h5/api
    
    // IP和地理位置
    private String userIp;
    private String ipCountry;
    private String ipRegion;
    private String ipCity;
    
    // 设备和浏览器信息
    private String userAgent;
    private String deviceType;      // mobile/tablet/desktop
    private String browserName;
    private String browserVersion;
    private String osName;
    private String osVersion;
    
    // 软删除相关
    @TableLogic
    private Integer isDeleted;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime deletedAt;
    
    // 时间戳
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;
    
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedAt;
    
    // 常用状态常量
    public static final Integer STATUS_FAILED = 0;
    public static final Integer STATUS_SUCCESS = 1;
    public static final Integer STATUS_PROCESSING = 2;
    
    // 解析来源常量
    public static final String SOURCE_MINIPROGRAM = "miniprogram";
    public static final String SOURCE_H5 = "h5";
    public static final String SOURCE_API = "api";
    
    // 平台常量
    public static final String PLATFORM_DOUYIN = "douyin";
    public static final String PLATFORM_TIKTOK = "tiktok";
    public static final String PLATFORM_KUAISHOU = "kuaishou";
    
    // 设备类型常量
    public static final String DEVICE_MOBILE = "mobile";
    public static final String DEVICE_TABLET = "tablet";
    public static final String DEVICE_DESKTOP = "desktop";
}